package gameObject;

import ui.ImageUtil;

import java.awt.*;
import java.awt.image.BufferedImage;

/*
状态区域，用于得分的显示
 */
public class Fettle {
    BufferedImage avatar;
    int amount = 0; //数量
    Grasp grasp;
    Wife wife;
    int empiric = 0;  //经验
    int grade;  //等级
    int speed = 10; //经验获取速度
    //称号
    String[] names = new String[]{" ","撩妹达人","撩妹狂魔","种草高手"};
    String name = names[0];
    public Fettle(Grasp grasp,Wife wife){
        this.grasp = grasp;
        this.wife = wife;
        avatar = ImageUtil.getImage("/Images/头像.png");
    }
    public void drawFet(Graphics g){
        g.setFont(new Font("微软雅黑",Font.BOLD,20));
        //得分和经验值
        g.setColor(Color.magenta);
        g.drawString("老婆已获得："+amount,5,25);
        g.drawString("经验值：",5,70);
        g.drawRect(80,53,250,20);
        g.setColor(Color.GREEN);
        g.fillRect(80,53, (int) (empiric*2.5),20);
        //头像框
        Graphics2D g2 = (Graphics2D) g;
        g2.setStroke(new BasicStroke(3.0f));
        g2.setColor(Color.BLACK);
        g2.drawRect(5,80,300,180);
        g.setColor(Color.CYAN);
        g2.fillRect(5,80,300,180);
        //头像
        g.drawImage(avatar,5,110,null);
        g.setColor(Color.BLACK);
        g.setFont(new Font("微软雅黑",Font.BOLD,30));
        g.drawString("等级："+grade,150,130);
        g.drawString("称号：",150,180);
        //调用逻辑方法
        logic(g);

    }
    public void logic(Graphics g){
        //逻辑代码
        if (grasp.getRect().intersects(wife.getRect())){
            g.setColor(Color.GREEN);
            g.setFont(new Font("华文行楷",Font.BOLD,50));
            g.drawString("已抓住老婆...",650,80);
        }
        if (wife.y < 108){
            System.out.println("已检测到");
            System.out.println("老婆的y坐标为："+wife.y);
            amount++;
            empiric += speed;
        }
        if (this.empiric >= 100){ //如果经验条满了
            this.empiric = 0;//经验条重置为0
            this.grade += 1;//等级加一
            this.speed -= 0.1;//经验获取的速度减慢,相当于是等级上限
        }
        //称号
        g.setFont(new Font("微软雅黑",Font.BOLD,35));
        g.setColor(Color.red);
        g.drawString(name,130,230);
        switch (grade){
            case 5:
                name = names[1];
                break;
            case 10:
                name = names[2];
                break;
            case 20:
                name = names[3];
                break;
        }
    }
}
